﻿<link href="~/Scripts/jquery-easyui-extensions/textbox/jeasyui.extensions.textbox.css" rel="stylesheet" />
<script src="~/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.setRequired.js"></script>
<script src="~/Scripts/jquery-easyui-extensions/textbox/jeasyui.extensions.textbox.setRequired.js"></script>

<div class="easyui-panel" data-options="fit:true,border:false" style="padding:20px;">
    <input id="btnTarget" type="text" class="easyui-textbox" value="" data-options="buttonText: '保存',buttonIcon:'icon-save',iconCls: 'icon-search',iconAlign: 'left',required:true" />
    <br /><br /><br /><br />
    <input name="requiredValue" type="radio" value="true" /> required 为 true，不能为空 &nbsp;
    <input name="requiredValue" type="radio" value="false" checked="checked" /> required 为 false，可以为空 &nbsp;
    <span style="color:red;">请自行选择要设置给上述 textbox 的 required 值</span>
    <br />
    <a id="btnSet" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">设置新的 required 值</a>
</div>

<script>
    $(function () {

        $("#btnSet").click(function () {
            var value = $("[name='requiredValue']:checked").val();

            $("#btnTarget").textbox("setRequired", value.toBoolean());
        });

    });
</script>